package pers.lx.crm.dao.info;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import pers.lx.crm.entiy.info.TagBlockDO;
import pers.lx.crm.entiy.info.TagDO;

import java.util.List;

/**
 * Created by lxl on 2017/2/28.
 */
@Repository
public interface TagBlockDao {

    @Select("select * from tag_block")
    public  List<TagBlockDO>  selectTagBlockListPage(TagBlockDO tagBlockDO) ;

    public void insertTagBlock(TagBlockDO tagBlockDO) ;

    @Update("update tag_block set description=#{description},name=#{name} where id=#{id}")
    public void updateTagBlock(TagBlockDO tagBlockDO) ;

    @Insert("insert into tag_label(tag_block_id,tag_list_id) values(#{0},#{1})")
    public void insertTagLabels(int tagBlockId,int tagListId) ;

    @Delete("delete from tag_label where tag_block_id = #{tagBlockId}")
    public void deleteTagLabels(int tagBlockId) ;

    @Delete("delete from tag_block where id=#{tagBlockId}")
    public void deleteTagBlock(int tagBlockId) ;

    @Select("select tag_list.id as id,tag_list.tag_kind_id,tag_list.name,tag_list.description,tag_list.required,tag_label.id as tag_label_id,tag_kind.kind from tag_list,tag_label,tag_kind where tag_list.id = tag_label.tag_list_id and tag_list.tag_kind_id=tag_kind.id and tag_label.tag_block_id =#{tagBlockId}")
    public List<TagDO> selectTagList(int tagBlockId) ;
}
